package com.zretc.auth.controller;

import com.zretc.api.pojo.SysUser;
import com.zretc.api.pojo.User;

import com.zretc.auth.service.UserService;
import com.zretc.common.entity.RespResult;
import com.zretc.security.entity.LoginUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;


    @PostMapping("/login")
    public RespResult login(@RequestBody User user){
        return userService.login(user);
    }

    @GetMapping("/getUserById")
    public User getUserInfoById(@RequestParam("userId") Integer userId){
        System.out.println("UserController-------------------------------------------------------------------------"); // test
        System.out.println(userId); // test

        return userService.getUserById(userId);
    }

    // UserFeignClient
    @GetMapping("/getUserByUsername")
    public User getUserInfoByUsername(@RequestParam("userName") String userName){
        return userService.getUserByUsername(userName);
    }

//    @PostMapping("/updatePointOrReputation")
//    public RespResult updatePointOrReputation(@RequestBody User user){
//        return userService.changePointOrRepu(user);
//    }
}
